﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

using Extensibility;
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.CommandBars;

namespace VSAddInFramework
{
    class ExternalCmd : VSCommand
    {
        public ExternalCmd()
             : base("ExtCmd", "ExtCmd", "Configure External Commands", true, 59,
            (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
            (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton)
        {
            Instance = this;
        }

        public override bool _Execute()
        {
            MessageBox.Show("ExtCmd");
            return true;
        }

        public override void  CreateCommandUI()
        {
            m_codeWindowButton = VSCommandUIMgr.AddCommandToToolbar(this, "Code Window");
        }

        public override void DestoryCommandUI()
        {
           if(m_codeWindowButton != null)
           {
               m_codeWindowButton.Delete(null);
           }
        }


        // methods used to manage external commands
        public void CreateCommands()
        {

        }

        private static ExternalCmd m_Instance;
        public static ExternalCmd Instance
        {
            get { return m_Instance; }
            set 
            {
                // make sure this class only instantiated once
                Debug.Assert(m_Instance == null); 
                m_Instance = value; 
            }

        }
        private CommandBarButton m_codeWindowButton;
    }
}
